package com.job.learn.cuiyt.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.job.learn.cuiyt.service.PersonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: cuiyutian1
 * @date: 2021/12/26 18:42
 * @description:
 */
@Slf4j
@Component
public class PersonJob implements SimpleJob {

    @Autowired
    private PersonService personService;

    @Override
    public void execute(ShardingContext shardingContext) {
        String shardingParameter = shardingContext.getShardingParameter();
        String taskId = shardingContext.getTaskId();
        log.info("定时任务开始：taskId:{},shardingParameter:{}",taskId,shardingParameter);
        personService.dealPerson(Integer.parseInt(shardingParameter));
    }
}
